<!DOCTYPE html>
<html lang="en">
<!-- cesium 百度 高德地图  -->

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
    <title>Hello World!</title>
    <script src="./Build/CesiumUnminified/Cesium.js"></script>
    <style>
        @import url(./templates/bucket.css);

        html,
        body,
        #cesiumContainer {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }
    </style>
</head>

<body>
    <div id="cesiumContainer" class="fullSize"></div>
    <div id="loadingOverlay">
        <h1>Loading...</h1>
    </div>
    <div id="toolbar"></div>
</body>
<script src="./js/baidu.js"></script>
<script>

    viewer = new Cesium.Viewer('cesiumContainer', {
        selectionIndicator: false,
        animation: false,
        baseLayerPicker: false,
        timeline: false,
        sceneModePicker: true,
        navigationHelpButton: false,
        useDefaultRenderLoop: true,
        showRenderLoopErrors: true,
        fullscreenButton: false,
        infoBox: false,
        imageryProvider: new BaiduImageryProvider({
            url: "http://online{s}.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles=pl&scaler=1&p=1"
        })
    });
    viewer.camera.setView({
        destination: Cesium.Cartesian3.fromDegrees(104.303854,24.871046, 100.0),
        //  [104.303854,24.871046, 0.0]

    }); //  设置初始位置
    // 分辨率调整函数
    let adjustmentPixel = function () {
        // 判断是否支持图像渲染像素化处理
        var supportsImageRenderingPixelated = viewer.cesiumWidget._supportsImageRenderingPixelated;
        if (supportsImageRenderingPixelated) {
            // 直接拿到设备的像素比例因子 - 如我设置的1.25
            var vtxf_dpr = window.devicePixelRatio;
            // 这个while我们在后面会做一个说明，但不是解决问题的说明
            while (vtxf_dpr >= 2.0) {
                vtxf_dpr /= 2.0;
            }
            // 设置渲染分辨率的比例因子
            viewer.resolutionScale = vtxf_dpr;
        }
    };
    adjustmentPixel();
    viewer.scene.postProcessStages.fxaa.enabled = false;
    //viewer.scene.globe.depthTestAgainstTerrain = true;
    viewer.scene.fxaa = false;
    let handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
    handler.setInputAction(function (event) {
        let earthPosition = viewer.camera.pickEllipsoid(event.position, viewer.scene.globe.ellipsoid);
        if (Cesium.defined(earthPosition)) {
            let ellipsoid = viewer.scene.globe.ellipsoid;
            let cartographic = ellipsoid.cartesianToCartographic(earthPosition);
            let lat = Cesium.Math.toDegrees(cartographic.latitude);
            let lon = Cesium.Math.toDegrees(cartographic.longitude);
        }
    }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
</script>

</html>